package com.deyuanyun.pic.docmger.controller.dto;

import com.deyuanyun.pic.common.util.StringUtils;
import com.deyuanyun.pic.docmger.domain.DocPipeline;
import com.deyuanyun.pic.settings.domain.pipe.PipeSegment;
import com.deyuanyun.pic.settings.support.utils.PipeDictUtils;

/**
 *  文档中心---管道相关扩展DTO
 *  @author axiao(xj08.dream@gmail.com)
 *  @date 2016-11-14
 *  @version 1.0
 *  Histroy: [修改人][时间][描述]
 */
public class DocPipelineDTO extends DocPipeline {

    private String pipeLineName; //管道名称

    private String segmentName; //管段名称

    private String fileRealName; //文件真实名字

    private String attachmentId;//附件id

    private String fileType;//文件类型

    public String getPipeLineName() {
        String pipeLineId = super.getPipeLineId();
        if(StringUtils.isNotEmpty(pipeLineId)) {
            return PipeDictUtils.getLineById(pipeLineId).getName();
        }
        return pipeLineName;
    }

    public void setPipeLineName(String pipeLineName) {
        this.pipeLineName = pipeLineName;
    }

    public String getSegmentName() {
        String segmentId = super.getPipeSegmentId();
        if(StringUtils.isNotEmpty(segmentId)) {
            PipeSegment pipeSegment = PipeDictUtils.getSegment(segmentId);
            return pipeSegment == null ? segmentName : pipeSegment.getName();
        }
        return segmentName;
    }

    public void setSegmentName(String segmentName) {
        this.segmentName = segmentName;
    }

    public String getFileRealName() {
        if(StringUtils.isNotEmpty(fileRealName)) {
            fileRealName = fileRealName.substring(0,fileRealName.lastIndexOf('.'));
        }
        return fileRealName;
    }

    public void setFileRealName(String fileRealName) {
        this.fileRealName = fileRealName;
    }

    public String getAttachmentId() {
        return attachmentId;
    }

    public void setAttachmentId(String attachmentId) {
        this.attachmentId = attachmentId;
    }

    public String getFileType() {
        return fileType;
    }

    public void setFileType(String fileType) {
        this.fileType = fileType;
    }
}
